package com.yrk.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import java.util.Date;
@WebListener
public class MySessionListener implements HttpSessionListener {
    @Override
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
        String beginTime=new Date().toString();
        HttpSession session=httpSessionEvent.getSession();
        System.out.println(beginTime+"创建了session："+session.getId());
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        String destoryTime=new Date().toString();
        HttpSession session=httpSessionEvent.getSession();
        System.out.println(destoryTime+"销毁了session："+session.getId());
    }
}
